﻿//////////#include <iostream>
//////////using namespace std;
//////////class Member
//////////{
//////////protected:
//////////	string name_;
//////////	int num_,score_;
//////////public:
//////////	Member(string name, int num, int score) :name_(name), num_(num), score_(score) {};
//////////	void add(int money)
//////////	{
//////////		score_ = score_+ money;
//////////	}
//////////	int exchange(int mount1)
//////////	{
//////////		score_ = score_ -  mount1 / 100*100;
//////////		return mount1 /100;
//////////	}
//////////	void print()
//////////	{
//////////		cout << "普通会员" << num_ << "--" << name_ << "--" << score_ << endl;
//////////	}
//////////};
//////////class VIP:public Member
//////////{
//////////protected:
//////////	int bl_, dl_;
//////////public:
//////////	VIP(string name, int num, int score, int bl, int dl) :Member(name, num, score), bl_(bl), dl_(dl) {};
//////////	void add(int money)
//////////	{
//////////		score_ = score_ + bl_*money;
//////////	}
//////////	int exchange(int mount1)
//////////	{
//////////		score_ = score_ - mount1/dl_*dl_;
//////////		return mount1 / dl_;
//////////	}
//////////	void print()
//////////	{
//////////		cout << "贵宾会员" << num_ << "--" << name_ << "--" << score_ << endl;
//////////	}
//////////};
//////////int main()
//////////{
//////////	string name1, name2;
//////////	int money1, mount1, money2, mount2, score1, score2, num1, num2, lb, db;
//////////	cin >> num1 >> name1 >> score1 >> money1 >> mount1 >> num2 >> name2 >> score2 >> lb >> db >> money2 >> mount2;
//////////	Member* pm;
//////////	Member member(name1, num1, score1);
//////////	pm = &member;
//////////	pm->add(money1);
//////////	pm->exchange(mount1);
//////////	pm->print();
//////////	VIP* pm1;
//////////	VIP vip(name2, num2, score2, lb, db);
//////////	pm1 = &vip;
//////////	pm1->add(money2);
//////////	pm1->exchange(mount2);
//////////	pm1->print();
//////////	return 0;
//////////}
//////////
////////#include <iostream>
////////using namespace std;
////////class Medel
////////{
////////protected:
////////	int yd, w, v;
////////public:
////////	Medel() {};
////////	Medel(int yd_, int w_, int v_) :yd(yd_), w(w_), v(v_) {};
////////	friend Medel operator +(Medel& c1, Medel& c2);
////////	friend  Medel operator *(Medel& c1, int n);
////////	Medel operator ++()
////////	{
////////		yd = yd + 1;
////////		v=v* (1 + 0.1);
////////		w = w * (1 + 0.1);
////////		return *this;
////////	}
////////	Medel operator --(int)
////////	{
////////		Medel temp = *this;
////////		yd = yd - 1;
////////		v= v* (1 - 0.1);
////////		w = w * (1 - 0.1);
////////		return temp;
////////	}
////////	void print()
////////	{
////////		cout << "硬度" << (int)yd << "--重量" << (int)w << "--体积" << (int)v << endl;
////////	}
////////};
////////Medel operator +(Medel& c1, Medel& c2)
////////{
////////	Medel a;
////////	a.yd = c1.yd + c2.yd;
////////	a.w = c1.w + c2.w;
////////	a.v = c1.v + c2.v;
////////	return a;
////////}
////////Medel operator *(Medel& c1,int n)
////////{
////////	Medel a;
////////	a.yd = c1.yd ;
////////	a.w = c1.w;
////////	a.v = c1.v * n;
////////	return a;
////////}
////////int main()
////////{
////////	int yd1, w1, v1, yd2, w2, v2, n;
////////	cin >> yd1 >> w1 >> v1 >> yd2 >> w2 >> v2 >> n;
////////	Medel m1(yd1, w1, v1);
////////	Medel m2(yd2, w2, v2);
////////	Medel m3 = m1 + m2;
////////	m3.print();
////////	Medel m4=m1*n;
////////	m4.print();
////////	Medel m5 = ++m1;
////////	m5.print();
////////	Medel m6 = m2--;
////////	m2.print();
////////	return 0;
////////}
//////#include <iostream>
//////using namespace std;
//////template<class T>
//////T Max(T arr[], int n)
//////{
//////	T max = arr[0];
//////	for (int i = 1; i < n; i++)
//////	{
//////		if (arr[i] > max)
//////		{
//////			max = arr[i];
//////		}
//////	}
//////	return max;
//////}
//////template<class T>
//////class Cryption
//////{
//////private:
//////	T p[100]; //明文
//////	T c[100]; //密文
//////	T key; //密钥
//////	int len; //长度
//////public:
//////	Cryption(T tk, T tt[], int n)//参数依次对应密钥、明文、长度
//////	{
//////		key = tk;
//////		len = n;
//////		for (int i = 0; i < n; i++)
//////		{
//////			p[i] = tt[i];
//////		}
//////	}
//////	void encrypt()//加密
//////	{
//////		T max = Max(p, len);
//////		for (int i = 0; i < len; i++)
//////		{
//////			p[i] = max - p[i];
//////		}
//////		for (int i = 0; i < len; i++)
//////		{
//////			c[i] = p[i] + key;
//////		}
//////	}
//////	void print() //打印，无需改造
//////	{
//////		int i;
//////		for (i = 0; i < len - 1; i++)
//////		{
//////			cout << c[i] << " ";
//////		}
//////		cout << c[i] << endl;
//////	}
//////};
//////int main()
//////{
//////	int my1, l1,it[100],l3;
//////	double my2, l2, d[100];
//////	char my3,c[100];
//////	cin >> my1 >> l1;
//////	for (int i = 0; i < l1; i++)
//////	{
//////		cin >> it[i];
//////	}
//////	Cryption<int> cry1(my1, it, l1);
//////	cry1.encrypt();
//////	cry1.print();
//////	cin >> my2>>l2;
//////	for (int i = 0; i < l2; i++)
//////	{
//////		cin >>d[i]; 
//////	}
//////	Cryption<double> cry2(my2, d, l2);
//////	cry2.encrypt();
//////	cry2.print();
//////	cin >> my3>>l3;
//////	for (int i = 0; i < l3; i++)
//////	{
//////		cin >> c[i];
//////	}
//////	Cryption<char>cry3(my3,c, l3);
//////	cry3.encrypt();
//////	cry3.print();
//////	return 0;
//////}
////
////{
////protected:
////	int num_, gv_;
////public:
////	Furniture(int num, int gv) :num_(num), gv_(gv) {};
////};
////class Fan:virtual public Furniture
////{
////protected:
////	int fx_, fl_;
////	Fan(int num,int gv,int fx, int fl) :Furniture(num,gv),fx_(fx), fl_(fl) {};
////	void setfanfx(int fx)
////	{
////		if (fx == 0)
////		{
////			cout << "定向吹风--";
////		}
////		else
////		{
////			cout << "旋转吹风--";
////		}
////	}
////	void setfanfl(int fl)
////	{
////		cout << "风力" << fl << "级" << endl;
////	}
////};
////class Humidifier :virtual public Furniture
////{
////protected:
////	double rl_, maxr_;
////	Humidifier(int num, int gv, double rl, double maxr) :Furniture(num, gv), rl_(rl), maxr_(maxr) {};
////	int predect()
////	{
////		if (rl_ >= 0.5 * maxr_)
////			return 1;
////		else if (rl_ >= 0.1 * maxr_ && rl_ <= 0.5 * maxr_)
////			return 2;
////		else
////			return 3;
////	}
////};
////class Hfan:public Fan,public Humidifier
////{
////protected:
////	int dw_;
////public:
////	Hfan(int num, int gv, int fx, int fl, double rl, double maxr, int dw) :Furniture(num, gv), Fan(num, gv, fx, fl), Humidifier(num, gv, rl, maxr), dw_(dw) {};
////	void set()
////	{
////		cout << "加湿风扇--档位" << dw_ << endl;
////		cout << "编号" << num_ << "--功率" << gv_ << "W" << endl;
////		if (dw_ == 1) 
////		{
////			setfanfx(0);
////			setfanfl(dw_);
////		}
////		else if(dw_==2)
////		{
////			setfanfx(1);
////			setfanfl(dw_);
////		}
////		else if (dw_ == 3)
////		{
////			setfanfx(1);
////			setfanfl(dw_);
////		}
////		else
////		{
////			setfanfx(0);
////			setfanfl(fl_);
////		}
////		if (predect() == 1)
////		{
////			cout << "实际水容量" << rl_ << "升--水量正常" << endl;
////		}
////		else if (predect() == 2)
////		{
////			cout << "实际水容量" << rl_ << "升--水量偏低" << endl;
////		}
////		else
////		{
////			cout << "实际水容量" << rl_ << "升--水量不足" << endl;
////		}
////	}
////};
////int main()
////{
////	int t,num,gv,fx,fl,dw,operate;
////	double rl, maxr;
////	cin >> t;
////	for (int i = 0; i < t; i++)
////	{
////		cin >> num >> gv >> fx >> fl >> rl >> maxr >> dw;
////		cin >> operate;
////		Hfan hfan(num, gv, fx, fl, rl, maxr, operate);
////		hfan.set();
////	}
////	return 0;
////}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
//class CN; //提前声明
//class EN; //提前声明
class Weight
{
protected:
	char kind[20]; //计重类型
	int gram; // 克
public:
	Weight(const char tk[] = "no name", int tg = 0)
	{
		strcpy(kind, tk);
		gram = tg;
	}
    virtual void print(ostream& out) = 0; // 输出不同类型的计重信息
};
class CN : public Weight
{
protected:
	int j, l, q;
public:
	CN():Weight("中国计重", 0), j(0), l(0), q(0) {};
	CN(int j_, int l_, int q_, int tg = 0,const char tk[] = "中国计重") :Weight(tk,tg),j(j_), l(l_), q(q_) {};
	void Convert(int g)
	{
		j= g /500;
		l = g % 500 / 50;
		q = g% 500 % 50 / 5;
		gram = g- 500 * j - 50 * l - 5 * q;
	}
	void print(ostream& out) 
	{
		out << kind << ":" << j << "斤" << l << "两" << q << "钱" << gram << "克" << endl;
	}
};
class EN : public Weight
{
protected:
	int b, a, dl;
public:
	EN( int b_, int a_, int dl_, int tg = 0,const char tk[] = "英国计重") :Weight(tk, tg), b(b_), a(a_), dl(dl_) {};
	void Convert(int g)
	{
		b= g/ 512;
		a = g % 512 / 32;
		dl = g % 512 % 32 / 2;
		gram = g - 512 * b - 32 * a - 2 * dl;
	}
	void print(ostream& out) 
	{
		out << kind << ":" << b << "磅" << a << "盎司" << dl << "打兰" << gram << "克" << endl;
	}
	operator CN()
	{
		int gr= b * 512 + a * 32 + dl * 2 + gram;
		CN cn;
		cn.Convert(gr);
		return cn;
	}
};
ostream& operator <<(ostream& out, Weight& c)
{
	 c.print(out);
	 return out;
}
int main()
{
	int tw;
	// 创建一个中国计重类对象cn
	// 构造参数对应斤、两、钱、克、类型，其中克和类型是对应基类属性gram和kind
	CN cn(0, 0, 0, 0, "中国计重");
	cin >> tw;
	cn.Convert(tw); // 把输入的克数转成中国计重
	cout << cn;
	// 创建英国计重类对象en
	// 构造参数对应磅、盎司、打兰、克、类型，其中克和类型是对应基类属性gram和kind
	EN en(0, 0, 0, 0, "英国计重");
	cin >> tw;
	en.Convert(tw); // 把输入的克数转成英国计重
	cout << en;
	cn = en;
	// 把英国计重转成中国计重
	cout << cn;
	return 0;
}
